<template>
    <!-- coser\商家管理 -->
    <EditTab @changeData="changeData"></EditTab>
   <UserTable :key="'index'+show.data"  :tabdata="show.data"></UserTable>
</template>

<script setup lang="ts">
import UserTable from '../../components/UserTable.vue'
import EditTab from '../../components/EditTab.vue'
import link from '@/util/api';
import { onBeforeMount, reactive, ref, watch, onMounted} from 'vue';
// const data:any = ref([])
const show = reactive({
data:[]
})
const changeData=(new_data:any)=>{
show.data = new_data
}
let num = 0;
const getMSG= async()=>{
await link('/getUsers').then( (res: any) => {
    num ++;
    show.data =  res.data.filter((res:any)=> res.categary==="商家")
})
console.log(`第${num}次执行，获取到的新数据为：`,show.data)
}
onMounted(() => {
getMSG()
})
watch(show.data,()=>{
getMSG()
},)


</script>

<style scoped lang="scss">

</style>